const mongoose = require('mongoose')
const Category = require('./Category')
const Schema = mongoose.Schema
const schema = new Schema(
  {
    image: { type: String },
    title: { type: String },
    author: {
      avatar: { type: String },
      name: { type: String },
      isVip: { type: Boolean }
    },
    price: { type: Number },
    readed: { type: Number },
    students: { type: Number },
    score: { type: Number },
    category: { type: mongoose.Schema.Types.ObjectId, ref: 'Category' }
  },
  {
    timestamps: {
      createdAt: 'created',
      updatedAt: 'updated'
    }
  }
)
module.exports = mongoose.model('Course', schema)
